{extend name="$base" /}
{block name="resources"}
<link rel="stylesheet" type="text/css" href="ADMIN_CSS/member_list.css" />
<script type="text/javascript" src="__STATIC__/My97DatePicker/WdatePicker.js"></script>

{/block}
{block name="main"}
<table class="mytable">
	<tr>
		<th width="20%" style="text-align: left;">
			<button class="btn-common btn-small" onclick="release()" style="margin:0 5px 0 0 !important;">手动释放</button>
		</th>
		<th>
			<span>到期时间</span>
			<input type="text" id='startDate' placeholder="请选择开始日期" class="input-medium" onclick="WdatePicker()"/>到
			<input type="text" id='endDate' placeholder="请选择结束日期" class="input-medium" onclick="WdatePicker()" />

			<select id="status" class="select-common middle">
				<option value ="-1">全部</option>
				<option value ="1">未到期</option>
				<option value ="2">已到期</option>
			</select>
			<input type="button" onclick="searchData()" value="搜索" class="btn-common" />
		</th>
	</tr>
</table>
<div>
	数据统计：本金：<span id="total_account_all"></span>，收益：<span id="get_money_all"></span>。
</div>
<table class="table-class">
	<thead>
		<tr align="center">
			<th ><i class="checkbox-common"><input type="checkbox" onclick="CheckAll(this)"></i></th>
			<th>会员</th>
			<th>开始时间</th>
			<th>到期时间</th>
			<th>本金</th>
			<th>收益</th>
			<th>发放时间</th>
			<th>锁定</th>
			<th>状态</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody></tbody>
</table>
{/block}
{block name="script"}
<script type="text/javascript">

    //搜索
    function searchData(){
        //alert(11111);
        LoadingInfo(1);
    }
	function LoadingInfo(page_index) {
		var level_id = $("#level_id").val();
        var status = $("#status").val();
		var start_date = $("#startDate").val();
		var end_date = $("#endDate").val();
	$.ajax({
		type : "post",
		url : document.location,
		data : {
		    "page_index" : page_index,
			"page_size" :  $("#showNumber").val(),
			"level_id" : level_id,
			"status" : status,
			"start_date":start_date,
			"end_date":end_date
		},
		success : function(data) {
			if (data["data"].length > 0) {
				$(".table-class tbody").empty();
				for (var i = 0; i < data["data"].length; i++) {
					var html = '';
					html += '<tr align="center">';
					html += '<td><i class="checkbox-common"><input name="sub" type="checkbox" value="'+ data["data"][i]["run_mill_id"]+'" ></i></td>';
                    html += '<td   onclick=view_Member('+ data["data"][i]["uid"] +')>'+ data["data"][i]["real_name"]+'<br>'+ data["data"][i]["user_tel"]+'</td>';
                    html += '<td>'+ timeStampTurnTime(data["data"][i]["add_time"])+'</td>';
					html += '<td>'+ timeStampTurnTime(data["data"][i]["send_time"])+'</td>';
                    html += '<td>'+ data["data"][i]["total_account"]+'</td>';
					html += '<td>'+ data["data"][i]["get_money"]+'</td>';
					html += '<td>'+ timeStampTurnTime(data["data"][i]["release_time"])+'</td>';
					html += '<td>'+ data["data"][i]["lock"]+'</td>';
                    html += '<td>'+ data["data"][i]["status"]+'</td>';
                    html += '<td>' +'<a onclick="delete_record('+ data["data"][i]["id"]+')">删除</a></td>';
					html += '</tr>';
					$(".table-class tbody").append(html);
				}
				$("#total_account_all").html(data.total_account_all);
				$("#get_money_all").html(data.get_money_all);
			} else {
				var html = '<tr align="center"><td colspan="11">暂无符合条件的数据记录</td></tr>';
				$(".table-class tbody").html(html);
			}
			initPageData(data["page_count"],data['data'].length,data['total_count']);
			$("#pageNumber").html(pagenumShow(jumpNumber,$("#page_count").val(),{$pageshow}));
		}
	});
}

//全选
function CheckAll(event){
	var checked = event.checked;
	$("#productTbody input[type = 'checkbox']").prop("checked",checked);
	if(checked) $(".table-class tbody input[type = 'checkbox']").parent().addClass("selected");
	else $(".table-class tbody input[type = 'checkbox']").parent().removeClass("selected");
}

// 删除记录
function delete_record(id){
    $( "#dialog" ).dialog({
        buttons: {
            "确定": function() {
                $.ajax({
                    type : "post",
                    url : "{:__URL('ADMIN_MAIN/Mine/tokenDel')}",
                    data : { "id" : id },
                    dataType : "json",
                    success : function(data) {
                        if(data["code"] > 0 ){
							LoadingInfo(getCurrentIndex(id,'#productTbody'));
                            showTip(data["message"],'success');
                            $("#chek_all").prop("checked", false);
                        }else{
                            showTip(data["message"],'error');
                        }
                    }
                });
                $(this).dialog('close');
            },
            "取消,#e57373": function() {
                $(this).dialog('close');
            },
        },
        contentText:"确定要删除吗？",
    });
}

	// 删除记录
	function release(){
		$( "#dialog" ).dialog({
			buttons: {
				"确定": function() {
					$.ajax({
						type : "post",
						url : "{:__URL('ADMIN_MAIN/Login/release')}",
						dataType : "json",
						success : function(data) {
							if(data["code"] > 0 ){
								LoadingInfo(1);
								showTip(data["message"],'success');
								$("#chek_all").prop("checked", false);
							}else{
								showTip(data["message"],'error');
							}
						}
					});
					$(this).dialog('close');
				},
				"取消,#e57373": function() {
					$(this).dialog('close');
				},
			},
			contentText:"确定要手动释放吗？",
		});
	}
</script>
{/block}